package com.jg.visitor.controller.module.reception;

import com.jg.visitor.annotation.Encrypt;
import com.jg.visitor.common.bean.DoorSettingBean;
import com.jg.visitor.common.bean.ResponseBean;
import com.jg.visitor.controller.dto.ApproverApproveRecordDTO;
import com.jg.visitor.controller.dto.VisitorApplyRecordDTO;
import com.jg.visitor.controller.vo.SignInOutVo;
import com.jg.visitor.service.GlobalConfigService;
import com.jg.visitor.service.VisitorApplyRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Api(tags = "接待人员接口")
@RestController
@RequestMapping("/api/reception")
public class ReceptionController {

    @Resource
    private VisitorApplyRecordService visitorApplyRecordService;
    @Resource
    private GlobalConfigService globalConfigService;

    @ApiOperation(value = "查询所有大门", notes = "查询所有大门")
    @GetMapping("/select-all-door")
    public ResponseBean selectAllDoor(){

        List<DoorSettingBean> result = globalConfigService.selectDoorSetting();

        return ResponseBean.success(result);
    }

    @ApiOperation("签到签退接口")
    @PostMapping("/in-out")
    @Encrypt
    public ResponseBean signInOut(@RequestBody SignInOutVo signInOutVo){
        ApproverApproveRecordDTO recordDetail = visitorApplyRecordService.signInOut(signInOutVo);

        return ResponseBean.success(recordDetail);
    }
}
